<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>iqc管理页面</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <link rel="stylesheet" href="/3nod_web/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/3nod_web/layui/css/soulTable.css" media="all"/>
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
    <style>
        #demo {
            zoom: 0.8;
        }
    </style>
</head>
<body>
<div>
    <!--添加查询条件-->
    <button type="button" class="layui-btn layui-btn-primary" onclick="acknowledgement();">查看承认书</button>
    <button type="button" class="layui-btn layui-btn-primary" onclick="check();">IQC检测</button>
</div>
<form class="layui-form" action="javascript:;" id="myform">
    <div class="demoTable">
        <div class="layui-form-item" style="margin-top: 20px">
            <div class="layui-inline">
                <label class="layui-form-label">送货单</label>
                <div class="layui-input-inline" style="width:168px;">
                    <input type="text" name="extReceiptForm" id="extReceiptForm" autocomplete="off" class="layui-input"
                    th:value="${session.extReceiptForm}">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">货主</label>
                <div class="layui-input-inline" style="width:168px;">
                    <input type="text" name="shipper" id="shipper" autocomplete="off" class="layui-input"
                           th:value="${session.shipper}">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">物料编码</label>
                <div class="layui-input-inline" style="width:168px;">
                    <input type="text" name="sku" id="sku" autocomplete="off" class="layui-input"
                           th:value="${session.sku}">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">检验类别</label>
                <div class="layui-input-inline" style="width:168px;">
                    <input type="text" name="inspectionCategoryDesc" id="inspectionCategoryDesc" autocomplete="off"
                           class="layui-input" th:value="${session.inspectionCategoryDesc}">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">供应商代码</label>
                <div class="layui-input-inline" style="width:168px;">
                    <input type="text" name="supplierKey" id="supplierKey" autocomplete="off" class="layui-input"
                           th:value="${session.supplierKey}">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">供应商名称</label>
                <div class="layui-input-inline" style="width:168px;">
                    <input type="text" name="supplierName" id="supplierName" autocomplete="off" class="layui-input"
                           th:value="${session.supplierName}">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label" style="width:100px;">检验项目状态</label>
                <div class="layui-input-inline " style="width: 130px;">
                    <select id="checkItemFlag" lay-search name="checkItemFlag">
                        <option value="">请选择</option>
                        <option value="Y">已检验</option>
                        <option value="N">待检验</option>
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <button id="search" class="layui-btn" data-type="reload">搜索</button>
            </div>

        </div>

    </div>
</form>

<table class="layui-hide" id="demo" lay-filter="demo"></table>
<script src="/3nod_web/layui/layui.js" charset="utf-8"></script>
<script src="/3nod_web/js/jquery-1.8.3.js" charset="utf-8"></script>
<script src="/3nod_web/js/iqc/iqcManager.js" charset="utf-8"></script>
<!--分页的前台核心代码-->
<script>
    layui.use('form', function(){

        layui.form.render();   //表单渲染，得渲染才会有效果显示出来
    })

    layui.use('table', function () {
        var table = layui.table;
        //方法级渲染
        table.render({
            elem: '#demo'
            , url: '/3nod_web/iqcDetection/list/'
            , cellMinWidth: 0
            , cols: [
                [
                    {checkbox: true, fixed: true}
                    , {field: 'receiptKey', title: 'ASN/收货单', sort: true, fixed: true, width: 150}
                    , {field: 'extReceiptForm', title: '送货单', width: 170}
                    , {field: 'shipper', title: '货主', width: 80}
                    , {field: 'sku', title: '物料编码', width: 115}
                    , {field: 'materialDesc', title: '物料描述', width: 115}
                    , {field: 'inspectionCategoryDesc', title: '检验品类', width: 115}
                    // , {field: 'inspectionCategory', title: '检验类别1', width: 115}
                    , {field: 'supplierKey', title: '供应商代码', width: 115}
                    , {field: 'supplierName', title: '供应商名称', width: 115}
                    , {field: 'receivedQty', title: '接收量', width: 115}
                    , {field: 'receiveTime', title: '收货时间', width: 115}
                    , {field: 'checkItemFlag', title: '检验项目状态', width: 115}
                    , {field: 'qualityStatus', title: '质检状态', width: 115}
                    , {field: 'loc', title: '储位', width: 115}
                    , {field: 'remark', title: '备注', width: 115}
                ]
            ]
            , id: 'testReload'
            , page: true
            , height: 'full-170'
            , limits: [20, 50, 100, 200, 500, 1000, 2000, 3000, 4000, 5000]
            , limit: 20
            , done: function () {
                //分类显示中文名称
                $("[data-field='qualityStatus']").children().each(function () {
                    if ($(this).text() == '1') {
                        $(this).text("待检")
                    } else if ($(this).text() == '2') {
                        $(this).text("质检中")
                    } else if ($(this).text() == '3') {
                        $(this).text("已完成")
                    }
                })

                $("[data-field='checkItemFlag']").children().each(function () {
                    if ($(this).text() == 'Y') {
                        $(this).text("已检验")
                    } else if ($(this).text() == 'N') {
                        $(this).text("待检验")
                    }
                })
            }
        });

        var $ = layui.$, active = {
            reload: function () {
                var receiptKey = $('#receiptKey');
                var shipper = $('#shipper');
                var sku = $('#sku');
                var supplierKey = $('#supplierKey');
                var supplierName = $('#supplierName');
                var extReceiptForm = $('#extReceiptForm');
                var receivedQty = $('#receivedQty');
                var receiveTime = $('#receiveTime');
                var qualityStatus = $('#qualityStatus');
                var loc = $('#loc');
                var remark = $('#remark');
                var inspectionCategoryDesc = $('#inspectionCategoryDesc');
                var checkItemFlag = $('#checkItemFlag');

                //执行重载
                table.reload('testReload', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    , where: {
                        receiptKey: receiptKey.val(),
                        shipper: shipper.val(),
                        sku: sku.val(),
                        supplierKey: supplierKey.val(),
                        supplierName: supplierName.val(),
                        extReceiptForm: extReceiptForm.val(),
                        receivedQty: receivedQty.val(),
                        receiveTime: receiveTime.val(),
                        qualityStatus: qualityStatus.val(),
                        loc: loc.val(),
                        remark: remark.val(),
                        inspectionCategoryDesc: inspectionCategoryDesc.val(),
                        checkItemFlag: checkItemFlag.val(),
                    }
                }, 'data');
            }
        };

        $('.demoTable .layui-btn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        //按回车提交
        $(".layui-input-inline").keydown(function (e) {//当按下按键时
            if (e.which == 13) {//.which属性判断按下的是哪个键，回车键的键位序号为13
                // $('button.search123').trigger("click");//触发搜索按钮的点击事件
                active['reload'] ? active['reload'].call(this) : '';
            }
        });

    });
</script>
</body>
</html>